<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Learning from Examples &raquo; Graph Traversal | Taskflow QuickStart</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
  <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
  <link rel="icon" href="favicon.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="theme-color" content="#22272e" />
</head>
<body>
<header><nav id="navigation">
  <div class="m-container">
    <div class="m-row">
      <span id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">
        <a href="https://taskflow.github.io"><img src="taskflow_logo.png" alt="" />Taskflow</a> <span class="m-breadcrumb">|</span> <a href="index.html" class="m-thin">QuickStart</a>
      </span>
      <div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
        <a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
          <path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
        </svg></a>
        <a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
        <a id="m-navbar-hide" href="#" title="Hide navigation"></a>
      </div>
      <div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
        <div class="m-row">
          <ol class="m-col-t-6 m-col-m-none">
            <li><a href="pages.html">Handbook</a></li>
            <li><a href="namespaces.html">Namespaces</a></li>
          </ol>
          <ol class="m-col-t-6 m-col-m-none" start="3">
            <li><a href="annotated.html">Classes</a></li>
            <li><a href="files.html">Files</a></li>
            <li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
              <use href="#m-doc-search-icon-path" />
            </svg></a></li>
          </ol>
        </div>
      </div>
    </div>
  </div>
</nav></header>
<main><article>
  <div class="m-container m-container-inflatable">
    <div class="m-row">
      <div class="m-col-l-10 m-push-l-1">
        <h1>
          <span class="m-breadcrumb"><a href="Examples.html">Learning from Examples</a> &raquo;</span>
          Graph Traversal
        </h1>
        <nav class="m-block m-default">
          <h3>Contents</h3>
          <ul>
            <li><a href="#GraphTraversalProblemFormulation">Problem Formulation</a></li>
            <li><a href="#GraphTraversalGraphRepresentation">Graph Representation</a></li>
            <li><a href="#GraphTraversalStaticTraversal">Static Traversal</a></li>
            <li><a href="#GraphTraversalDynamicTraversal">Dynamic Traversal</a></li>
          </ul>
        </nav>
<p>We study the graph traversal problem by visiting each vertex in parallel following their edge dependencies. Traversing a graph is a fundamental building block of many graph applications especially for large-scale graph analytics.</p><section id="GraphTraversalProblemFormulation"><h2><a href="#GraphTraversalProblemFormulation">Problem Formulation</a></h2><p>Given a directed acyclic graph (DAG), i.e., a graph that has no cycles, we would like to traverse each vertex in order without breaking dependency constraints defined by edges. The following figure shows a graph of six vertices and seven edges. Each vertex represents a particular task and each edge represents a task dependency between two tasks.</p><div class="m-graph"><svg style="width: 18.900rem; height: 26.000rem;" viewBox="0.00 0.00 189.00 260.00">
<g transform="scale(1 1) rotate(0) translate(4 256)">
<title>Taskflow</title>
<g class="m-node m-flat">
<title>Task1</title>
<ellipse cx="99" cy="-234" rx="27" ry="18"/>
<text text-anchor="middle" x="99" y="-230.12" font-family="Helvetica,sans-Serif" font-size="10.00">Task1</text>
</g>
<g class="m-node m-flat">
<title>Task2</title>
<ellipse cx="27" cy="-162" rx="27" ry="18"/>
<text text-anchor="middle" x="27" y="-158.12" font-family="Helvetica,sans-Serif" font-size="10.00">Task2</text>
</g>
<g class="m-edge">
<title>Task1&#45;&gt;Task2</title>
<path d="M84.08,-218.5C74.23,-208.92 61.14,-196.19 49.97,-185.34"/>
<polygon points="52.59,-183 42.98,-178.54 47.71,-188.02 52.59,-183"/>
</g>
<g class="m-node m-flat">
<title>Task3</title>
<ellipse cx="99" cy="-162" rx="27" ry="18"/>
<text text-anchor="middle" x="99" y="-158.12" font-family="Helvetica,sans-Serif" font-size="10.00">Task3</text>
</g>
<g class="m-edge">
<title>Task1&#45;&gt;Task3</title>
<path d="M99,-215.7C99,-208.41 99,-199.73 99,-191.54"/>
<polygon points="102.5,-191.62 99,-181.62 95.5,-191.62 102.5,-191.62"/>
</g>
<g class="m-node m-flat">
<title>Task4</title>
<ellipse cx="154" cy="-90" rx="27" ry="18"/>
<text text-anchor="middle" x="154" y="-86.12" font-family="Helvetica,sans-Serif" font-size="10.00">Task4</text>
</g>
<g class="m-edge">
<title>Task1&#45;&gt;Task4</title>
<path d="M111.75,-217.7C119.56,-207.59 129.15,-193.71 135,-180 143.26,-160.66 148.06,-137.38 150.77,-119.48"/>
<polygon points="154.21,-120.21 152.1,-109.83 147.27,-119.26 154.21,-120.21"/>
</g>
<g class="m-node m-flat">
<title>Task5</title>
<ellipse cx="82" cy="-90" rx="27" ry="18"/>
<text text-anchor="middle" x="82" y="-86.12" font-family="Helvetica,sans-Serif" font-size="10.00">Task5</text>
</g>
<g class="m-edge">
<title>Task2&#45;&gt;Task5</title>
<path d="M39.21,-145.46C46.11,-136.67 54.91,-125.48 62.73,-115.53"/>
<polygon points="65.47,-117.71 68.89,-107.68 59.96,-113.38 65.47,-117.71"/>
</g>
<g class="m-edge">
<title>Task3&#45;&gt;Task5</title>
<path d="M94.88,-144.05C93.07,-136.6 90.9,-127.64 88.85,-119.22"/>
<polygon points="92.31,-118.64 86.55,-109.75 85.51,-120.29 92.31,-118.64"/>
</g>
<g class="m-node m-flat">
<title>Task6</title>
<ellipse cx="118" cy="-18" rx="27" ry="18"/>
<text text-anchor="middle" x="118" y="-14.12" font-family="Helvetica,sans-Serif" font-size="10.00">Task6</text>
</g>
<g class="m-edge">
<title>Task4&#45;&gt;Task6</title>
<path d="M145.65,-72.76C141.42,-64.55 136.19,-54.37 131.42,-45.09"/>
<polygon points="134.68,-43.79 127,-36.49 128.46,-46.99 134.68,-43.79"/>
</g>
<g class="m-edge">
<title>Task5&#45;&gt;Task6</title>
<path d="M90.35,-72.76C94.58,-64.55 99.81,-54.37 104.58,-45.09"/>
<polygon points="107.54,-46.99 109,-36.49 101.32,-43.79 107.54,-46.99"/>
</g>
</g>
</svg>
</div><p>Traversing the above graph in parallel, the maximum parallelism we can acquire is three. When Task1 finishes, we can run Task2, Task3, and Task4 in parallel.</p></section><section id="GraphTraversalGraphRepresentation"><h2><a href="#GraphTraversalGraphRepresentation">Graph Representation</a></h2><p>We define the data structure of our graph. The graph is represented by an array of nodes of the following structure:</p><pre class="m-code"><span class="k">struct</span><span class="w"> </span><span class="nc">Node</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="n">name</span><span class="p">;</span>
<span class="w">  </span><span class="kt">size_t</span><span class="w"> </span><span class="n">idx</span><span class="p">;</span><span class="w">                          </span><span class="c1">// index of the node in a array</span>
<span class="w">  </span><span class="kt">bool</span><span class="w"> </span><span class="n">visited</span><span class="w"> </span><span class="p">{</span><span class="nb">false</span><span class="p">};</span>

<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">atomic</span><span class="o">&lt;</span><span class="kt">size_t</span><span class="o">&gt;</span><span class="w"> </span><span class="n">dependents</span><span class="w"> </span><span class="p">{</span><span class="mi">0</span><span class="p">};</span><span class="w">  </span><span class="c1">// number of incoming edges</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">Node</span><span class="o">*&gt;</span><span class="w"> </span><span class="n">successors</span><span class="p">;</span><span class="w">       </span><span class="c1">// number of outgoing edges</span>

<span class="w">  </span><span class="kt">void</span><span class="w"> </span><span class="nf">precede</span><span class="p">(</span><span class="n">Node</span><span class="o">&amp;</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">successors</span><span class="p">.</span><span class="n">emplace_back</span><span class="p">(</span><span class="o">&amp;</span><span class="n">n</span><span class="p">);</span>
<span class="w">    </span><span class="n">n</span><span class="p">.</span><span class="n">dependents</span><span class="w"> </span><span class="o">++</span><span class="p">;</span>
<span class="w">  </span><span class="p">}</span>
<span class="p">};</span></pre><p>Based on the data structure, we randomly generate a DAG using ordered edges.</p><pre class="m-code"><span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o">&lt;</span><span class="n">Node</span><span class="p">[]</span><span class="o">&gt;</span><span class="w"> </span><span class="n">make_dag</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">num_nodes</span><span class="p">,</span><span class="w"> </span><span class="kt">size_t</span><span class="w"> </span><span class="n">max_degree</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o">&lt;</span><span class="n">Node</span><span class="p">[]</span><span class="o">&gt;</span><span class="w"> </span><span class="n">nodes</span><span class="p">(</span><span class="k">new</span><span class="w"> </span><span class="n">Node</span><span class="p">[</span><span class="n">num_nodes</span><span class="p">]);</span>
<span class="w">  </span>
<span class="w">  </span><span class="c1">// Make sure nodes are in clean state</span>
<span class="w">  </span><span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">idx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<span class="w">    </span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">to_string</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
<span class="w">  </span><span class="p">}</span>

<span class="w">  </span><span class="c1">// Create a DAG by randomly insert ordered edges</span>
<span class="w">  </span><span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="kt">size_t</span><span class="w"> </span><span class="n">degree</span><span class="w"> </span><span class="p">{</span><span class="mi">0</span><span class="p">};</span>
<span class="w">    </span><span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">j</span><span class="o">=</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">j</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">degree</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">max_degree</span><span class="p">;</span><span class="w"> </span><span class="n">j</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="k">if</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">rand</span><span class="p">()</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">        </span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">precede</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">j</span><span class="p">]);</span>
<span class="w">        </span><span class="n">degree</span><span class="w"> </span><span class="o">++</span><span class="p">;</span>
<span class="w">      </span><span class="p">}</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">  </span><span class="p">}</span>

<span class="w">  </span><span class="k">return</span><span class="w"> </span><span class="n">nodes</span><span class="p">;</span>
<span class="p">}</span></pre><p>The function, <code>make_dag</code>, accepts two arguments, <code>num_nodes</code> and <code>max_degree</code>, to restrict the number of nodes in the graph and the maximum number of outgoing edges of every node.</p></section><section id="GraphTraversalStaticTraversal"><h2><a href="#GraphTraversalStaticTraversal">Static Traversal</a></h2><p>We create a taskflow to traverse the graph using static tasks (see <a href="StaticTasking.html" class="m-doc">Static Tasking</a>). Each task does nothing but marks <code>visited</code> to <code>true</code> and subtracts <code>dependents</code> from one, both of which are used for validation after the graph is traversed. In practice, this computation may be replaced with a heavy function.</p><pre class="m-code"><span class="n">tf</span><span class="o">::</span><span class="n">Taskflow</span><span class="w"> </span><span class="n">taskflow</span><span class="p">;</span>
<span class="n">tf</span><span class="o">::</span><span class="n">Executor</span><span class="w"> </span><span class="n">executor</span><span class="p">;</span>

<span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o">&lt;</span><span class="n">Node</span><span class="p">[]</span><span class="o">&gt;</span><span class="w"> </span><span class="n">nodes</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">make_dag</span><span class="p">(</span><span class="mi">100000</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">);</span>
<span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">tf</span><span class="o">::</span><span class="n">Task</span><span class="o">&gt;</span><span class="w"> </span><span class="n">tasks</span><span class="p">;</span>

<span class="c1">// create the traversal task for each node</span>
<span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">tf</span><span class="o">::</span><span class="n">Task</span><span class="w"> </span><span class="n">task</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">taskflow</span><span class="p">.</span><span class="n">emplace</span><span class="p">([</span><span class="n">v</span><span class="o">=&amp;</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">])](){</span>
<span class="w">    </span><span class="n">v</span><span class="o">-&gt;</span><span class="n">visited</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">true</span><span class="p">;</span>
<span class="w">    </span><span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">j</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">j</span><span class="o">&lt;</span><span class="n">v</span><span class="o">-&gt;</span><span class="n">successors</span><span class="p">.</span><span class="n">size</span><span class="p">();</span><span class="w"> </span><span class="o">++</span><span class="n">j</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="n">v</span><span class="o">-&gt;</span><span class="n">successors</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">-&gt;</span><span class="n">dependents</span><span class="p">.</span><span class="n">fetch_sub</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">  </span><span class="p">}).</span><span class="n">name</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">name</span><span class="p">);</span>

<span class="w">  </span><span class="n">tasks</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="n">task</span><span class="p">);</span>
<span class="p">}</span>

<span class="c1">// create the dependency between nodes on top of the graph structure</span>
<span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">j</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">j</span><span class="o">&lt;</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">successors</span><span class="p">.</span><span class="n">size</span><span class="p">();</span><span class="w"> </span><span class="o">++</span><span class="n">j</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">tasks</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">precede</span><span class="p">(</span><span class="n">tasks</span><span class="p">[</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">successors</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">-&gt;</span><span class="n">idx</span><span class="p">]);</span>
<span class="w">  </span><span class="p">}</span>
<span class="p">}</span>

<span class="n">executor</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">taskflow</span><span class="p">).</span><span class="n">wait</span><span class="p">();</span>

<span class="c1">// after the graph is traversed, all nodes must be visited with no dependents</span>
<span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">assert</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">visited</span><span class="p">);</span>
<span class="w">  </span><span class="n">assert</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">dependents</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span>
<span class="p">}</span></pre><p>The code above has two parts to construct the parallel graph traversal. First, it iterates each node and constructs a traversal task for that node. Second, it iterates each outgoing edge of a node and creates a dependency between the node and the other end (successor) of that edge. The resulting taskflow structure is topologically equivalent to the given graph.</p><div class="m-graph"><svg style="width: 159.200rem; height: 63.200rem;" viewBox="0.00 0.00 1592.00 632.00">
<g transform="scale(1 1) rotate(0) translate(4 628)">
<title>Taskflow</title>
<g class="m-node m-flat">
<title>p0x7f95e780b0d0</title>
<ellipse cx="27" cy="-138" rx="27" ry="18"/>
<text text-anchor="middle" x="27" y="-134.12" font-family="Helvetica,sans-Serif" font-size="10.00">0</text>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780ac50</title>
<ellipse cx="117" cy="-258" rx="27" ry="18"/>
<text text-anchor="middle" x="117" y="-254.12" font-family="Helvetica,sans-Serif" font-size="10.00">4</text>
</g>
<g class="m-edge">
<title>p0x7f95e780b0d0&#45;&gt;p0x7f95e780ac50</title>
<path d="M39.87,-154.18C54.63,-174.31 80,-208.91 97.37,-232.59"/>
<polygon points="94.41,-234.47 103.14,-240.47 100.05,-230.34 94.41,-234.47"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780ab30</title>
<ellipse cx="117" cy="-312" rx="27" ry="18"/>
<text text-anchor="middle" x="117" y="-308.12" font-family="Helvetica,sans-Serif" font-size="10.00">5</text>
</g>
<g class="m-edge">
<title>p0x7f95e780b0d0&#45;&gt;p0x7f95e780ab30</title>
<path d="M36.83,-155C42.06,-165.31 48.68,-178.79 54,-191 71.87,-232.01 66,-247.24 90,-285 90.87,-286.37 91.82,-287.74 92.83,-289.08"/>
<polygon points="89.86,-290.99 99.01,-296.34 95.19,-286.46 89.86,-290.99"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a8f0</title>
<ellipse cx="207" cy="-174" rx="27" ry="18"/>
<text text-anchor="middle" x="207" y="-170.12" font-family="Helvetica,sans-Serif" font-size="10.00">7</text>
</g>
<g class="m-edge">
<title>p0x7f95e780b0d0&#45;&gt;p0x7f95e780a8f0</title>
<path d="M50.47,-128.71C74.35,-120.25 112.86,-110.67 144,-122 159.78,-127.74 174.34,-139.46 185.38,-150.32"/>
<polygon points="182.6,-152.47 192.05,-157.25 187.64,-147.62 182.6,-152.47"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a7d0</title>
<ellipse cx="297" cy="-182" rx="27" ry="18"/>
<text text-anchor="middle" x="297" y="-178.12" font-family="Helvetica,sans-Serif" font-size="10.00">8</text>
</g>
<g class="m-edge">
<title>p0x7f95e780b0d0&#45;&gt;p0x7f95e780a7d0</title>
<path d="M52.42,-131.19C91.98,-121.43 171.9,-107.02 234,-130 249.64,-135.79 264.11,-147.4 275.13,-158.18"/>
<polygon points="272.33,-160.31 281.8,-165.06 277.36,-155.44 272.33,-160.31"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ac50&#45;&gt;p0x7f95e780a8f0</title>
<path d="M133.33,-243.37C146.87,-230.44 166.84,-211.38 182.42,-196.51"/>
<polygon points="184.64,-199.23 189.46,-189.79 179.81,-194.16 184.64,-199.23"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ac50&#45;&gt;p0x7f95e780a7d0</title>
<path d="M140.18,-248.53C171.1,-235.33 227.35,-211.31 263.14,-196.03"/>
<polygon points="264.32,-199.33 272.14,-192.19 261.57,-192.89 264.32,-199.33"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780aa10</title>
<ellipse cx="207" cy="-388" rx="27" ry="18"/>
<text text-anchor="middle" x="207" y="-384.12" font-family="Helvetica,sans-Serif" font-size="10.00">6</text>
</g>
<g class="m-edge">
<title>p0x7f95e780ac50&#45;&gt;p0x7f95e780aa10</title>
<path d="M133.21,-272.6C136.92,-276.47 140.75,-280.77 144,-285 162.58,-309.23 180.17,-339.4 191.84,-360.81"/>
<polygon points="188.69,-362.35 196.5,-369.51 194.86,-359.04 188.69,-362.35"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a6b0</title>
<ellipse cx="297" cy="-334" rx="27" ry="18"/>
<text text-anchor="middle" x="297" y="-330.12" font-family="Helvetica,sans-Serif" font-size="10.00">9</text>
</g>
<g class="m-edge">
<title>p0x7f95e780ac50&#45;&gt;p0x7f95e780a6b0</title>
<path d="M140.18,-267.47C171.1,-280.67 227.35,-304.69 263.14,-319.97"/>
<polygon points="261.57,-323.11 272.14,-323.81 264.32,-316.67 261.57,-323.11"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ab30&#45;&gt;p0x7f95e780a8f0</title>
<path d="M133.3,-297.48C137.01,-293.6 140.82,-289.29 144,-285 163.75,-258.37 181.67,-224.77 193.1,-201.55"/>
<polygon points="196.17,-203.26 197.37,-192.74 189.87,-200.21 196.17,-203.26"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ab30&#45;&gt;p0x7f95e780a6b0</title>
<path d="M143.88,-315.2C174.2,-318.95 224.66,-325.18 259.08,-329.44"/>
<polygon points="258.23,-332.86 268.58,-330.61 259.09,-325.91 258.23,-332.86"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a470</title>
<ellipse cx="387" cy="-236" rx="27" ry="18"/>
<text text-anchor="middle" x="387" y="-232.12" font-family="Helvetica,sans-Serif" font-size="10.00">11</text>
</g>
<g class="m-edge">
<title>p0x7f95e780ab30&#45;&gt;p0x7f95e780a470</title>
<path d="M142.26,-305.12C189.77,-291.65 295.29,-261.72 350.6,-246.04"/>
<polygon points="351.48,-249.43 360.15,-243.33 349.57,-242.69 351.48,-249.43"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a110</title>
<ellipse cx="657" cy="-342" rx="27" ry="18"/>
<text text-anchor="middle" x="657" y="-338.12" font-family="Helvetica,sans-Serif" font-size="10.00">14</text>
</g>
<g class="m-edge">
<title>p0x7f95e780ab30&#45;&gt;p0x7f95e780a110</title>
<path d="M124.03,-329.57C141.89,-378.03 199.39,-510 296,-510 296,-510 296,-510 478,-510 535.64,-510 552.24,-491.73 594,-452 618.13,-429.04 635.46,-394.59 645.56,-370.37"/>
<polygon points="648.79,-371.71 649.25,-361.13 642.29,-369.11 648.79,-371.71"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a8f0&#45;&gt;p0x7f95e780a7d0</title>
<path d="M233.93,-176.36C241.65,-177.06 250.26,-177.84 258.56,-178.6"/>
<polygon points="258.17,-182.08 268.45,-179.5 258.8,-175.1 258.17,-182.08"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a8f0&#45;&gt;p0x7f95e780a6b0</title>
<path d="M217.25,-190.82C232.46,-218.48 262.88,-273.79 281.14,-306.99"/>
<polygon points="277.99,-308.52 285.88,-315.6 284.13,-305.15 277.99,-308.52"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a590</title>
<ellipse cx="297" cy="-125" rx="27" ry="18"/>
<text text-anchor="middle" x="297" y="-121.12" font-family="Helvetica,sans-Serif" font-size="10.00">10</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a8f0&#45;&gt;p0x7f95e780a590</title>
<path d="M228.41,-162.64C239.52,-156.45 253.47,-148.68 265.81,-141.81"/>
<polygon points="267.34,-144.96 274.38,-137.04 263.94,-138.85 267.34,-144.96"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a230</title>
<ellipse cx="567" cy="-152" rx="27" ry="18"/>
<text text-anchor="middle" x="567" y="-148.12" font-family="Helvetica,sans-Serif" font-size="10.00">13</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a8f0&#45;&gt;p0x7f95e780a230</title>
<path d="M216.13,-156.92C225.98,-138.48 244.47,-110.12 270,-98 360.22,-55.17 480.77,-106.43 536.03,-135.13"/>
<polygon points="534.07,-138.05 544.54,-139.66 537.35,-131.87 534.07,-138.05"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a7d0&#45;&gt;p0x7f95e780a470</title>
<path d="M317.53,-193.98C329.15,-201.12 344.11,-210.3 357.08,-218.25"/>
<polygon points="354.88,-221.01 365.23,-223.26 358.54,-215.04 354.88,-221.01"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a7d0&#45;&gt;p0x7f95e780a110</title>
<path d="M323.51,-185.79C347.44,-189.84 383.94,-197.31 414,-209 473.91,-232.3 483.65,-249.07 540,-280 568.64,-295.72 601.51,-313.24 624.92,-325.63"/>
<polygon points="623.15,-328.65 633.63,-330.23 626.42,-322.47 623.15,-328.65"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780a350</title>
<ellipse cx="477" cy="-388" rx="27" ry="18"/>
<text text-anchor="middle" x="477" y="-384.12" font-family="Helvetica,sans-Serif" font-size="10.00">12</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a7d0&#45;&gt;p0x7f95e780a350</title>
<path d="M309.68,-198.18C321.83,-214.79 341.62,-241.21 360,-263 391.08,-299.84 429.54,-340.38 453.43,-365.01"/>
<polygon points="450.69,-367.22 460.18,-371.94 455.71,-362.34 450.69,-367.22"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a7d0&#45;&gt;p0x7f95e780a230</title>
<path d="M323.7,-179.12C371.3,-173.79 473.36,-162.37 528.62,-156.18"/>
<polygon points="528.93,-159.67 538.48,-155.08 528.16,-152.71 528.93,-159.67"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780afb0</title>
<ellipse cx="27" cy="-386" rx="27" ry="18"/>
<text text-anchor="middle" x="27" y="-382.12" font-family="Helvetica,sans-Serif" font-size="10.00">1</text>
</g>
<g class="m-edge">
<title>p0x7f95e780afb0&#45;&gt;p0x7f95e780ab30</title>
<path d="M44.55,-372.08C57.5,-361.19 75.72,-345.87 90.53,-333.42"/>
<polygon points="92.66,-336.2 98.06,-327.08 88.16,-330.84 92.66,-336.2"/>
</g>
<g class="m-edge">
<title>p0x7f95e780afb0&#45;&gt;p0x7f95e780a8f0</title>
<path d="M34.29,-368.23C48.01,-329.81 80.18,-241.6 90,-231 101.95,-218.1 142.76,-199.63 172.6,-187.24"/>
<polygon points="173.7,-190.58 181.63,-183.55 171.05,-184.1 173.7,-190.58"/>
</g>
<g class="m-edge">
<title>p0x7f95e780afb0&#45;&gt;p0x7f95e780aa10</title>
<path d="M49.52,-396.59C61.19,-401.75 76.04,-407.39 90,-410 113.59,-414.41 120.35,-414.07 144,-410 153.68,-408.33 163.86,-405.3 173.1,-402.01"/>
<polygon points="174.3,-405.3 182.41,-398.48 171.82,-398.76 174.3,-405.3"/>
</g>
<g class="m-edge">
<title>p0x7f95e780afb0&#45;&gt;p0x7f95e780a6b0</title>
<path d="M44.63,-400.12C56.44,-409.18 73.14,-420.14 90,-425 151.64,-442.78 178.14,-446.55 234,-415 255.63,-402.79 272.17,-379.64 282.7,-361.21"/>
<polygon points="285.67,-363.08 287.35,-352.62 279.51,-359.75 285.67,-363.08"/>
</g>
<g class="m-edge">
<title>p0x7f95e780aa10&#45;&gt;p0x7f95e780a6b0</title>
<path d="M227.53,-376.02C239.15,-368.88 254.11,-359.7 267.08,-351.75"/>
<polygon points="268.54,-354.96 275.23,-346.74 264.88,-348.99 268.54,-354.96"/>
</g>
<g class="m-edge">
<title>p0x7f95e780aa10&#45;&gt;p0x7f95e780a110</title>
<path d="M224.45,-401.87C254.47,-425.73 321.08,-472 386,-472 386,-472 386,-472 478,-472 534.68,-472 549.25,-453.79 594,-419 612.18,-404.87 628.33,-384.4 639.59,-368.12"/>
<polygon points="642.45,-370.14 645.1,-359.88 636.63,-366.25 642.45,-370.14"/>
</g>
<g class="m-edge">
<title>p0x7f95e780aa10&#45;&gt;p0x7f95e780a590</title>
<path d="M210.02,-369.75C215.09,-329.08 230.91,-228.8 270,-155 271.15,-152.82 272.49,-150.67 273.94,-148.57"/>
<polygon points="276.41,-151.09 279.84,-141.07 270.91,-146.77 276.41,-151.09"/>
</g>
<g class="m-edge">
<title>p0x7f95e780aa10&#45;&gt;p0x7f95e780a350</title>
<path d="M234.18,-388C281.92,-388 383.23,-388 438.36,-388"/>
<polygon points="438.2,-391.5 448.2,-388 438.2,-384.5 438.2,-391.5"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a6b0&#45;&gt;p0x7f95e780a470</title>
<path d="M311.75,-318.69C325.87,-302.96 348.06,-278.25 364.5,-259.94"/>
<polygon points="366.97,-262.43 371.04,-252.65 361.76,-257.76 366.97,-262.43"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a6b0&#45;&gt;p0x7f95e780a110</title>
<path d="M315.41,-347.56C342.4,-367.53 396.76,-403.7 450,-415 513.27,-428.43 536.15,-422.92 594,-394 608.67,-386.66 622.86,-375.2 633.95,-364.9"/>
<polygon points="636.29,-367.51 641.05,-358.04 631.43,-362.48 636.29,-367.51"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a6b0&#45;&gt;p0x7f95e780a350</title>
<path d="M322.01,-341.28C352.66,-350.58 405.94,-366.74 441.08,-377.41"/>
<polygon points="439.77,-380.67 450.36,-380.22 441.8,-373.97 439.77,-380.67"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a6b0&#45;&gt;p0x7f95e780a230</title>
<path d="M318.69,-323.03C356.76,-302.48 439.86,-255.93 504,-208 517.7,-197.76 531.94,-185.07 543.31,-174.36"/>
<polygon points="545.49,-177.12 550.29,-167.68 540.65,-172.06 545.49,-177.12"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780ae90</title>
<ellipse cx="27" cy="-218" rx="27" ry="18"/>
<text text-anchor="middle" x="27" y="-214.12" font-family="Helvetica,sans-Serif" font-size="10.00">2</text>
</g>
<g class="m-edge">
<title>p0x7f95e780ae90&#45;&gt;p0x7f95e780ab30</title>
<path d="M41.95,-233.25C54.46,-246.88 73.36,-267.37 90,-285 91.14,-286.21 92.32,-287.45 93.51,-288.7"/>
<polygon points="90.88,-291.02 100.32,-295.82 95.94,-286.18 90.88,-291.02"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ae90&#45;&gt;p0x7f95e780a8f0</title>
<path d="M39.63,-201.68C50.74,-187.63 68.89,-168.34 90,-160 116.43,-149.56 148.67,-154.74 172.44,-161.57"/>
<polygon points="171.34,-164.89 181.93,-164.54 173.43,-158.21 171.34,-164.89"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ae90&#45;&gt;p0x7f95e780a7d0</title>
<path d="M37.83,-201C48.37,-184.6 66.79,-160.71 90,-150 148.12,-123.17 172.09,-130.73 234,-147 246.01,-150.16 258.15,-156.23 268.46,-162.44"/>
<polygon points="266.51,-165.35 276.82,-167.78 270.28,-159.45 266.51,-165.35"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ae90&#45;&gt;p0x7f95e780aa10</title>
<path d="M39.48,-234.38C44.24,-241.48 49.65,-249.99 54,-258 72.79,-292.62 61.89,-311.4 90,-339 111.92,-360.51 144.71,-373.17 169.85,-380.21"/>
<polygon points="168.76,-383.55 179.32,-382.69 170.53,-376.78 168.76,-383.55"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e780ad70</title>
<ellipse cx="27" cy="-285" rx="27" ry="18"/>
<text text-anchor="middle" x="27" y="-281.12" font-family="Helvetica,sans-Serif" font-size="10.00">3</text>
</g>
<g class="m-edge">
<title>p0x7f95e780ad70&#45;&gt;p0x7f95e780ac50</title>
<path d="M52.05,-277.62C60.97,-274.88 71.29,-271.72 80.99,-268.74"/>
<polygon points="82,-272.09 90.54,-265.81 79.95,-265.4 82,-272.09"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ad70&#45;&gt;p0x7f95e780ab30</title>
<path d="M52.05,-292.38C60.97,-295.12 71.29,-298.28 80.99,-301.26"/>
<polygon points="79.95,-304.6 90.54,-304.19 82,-297.91 79.95,-304.6"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ad70&#45;&gt;p0x7f95e780a8f0</title>
<path d="M38.77,-268.55C54.58,-244.64 82.93,-202.61 90,-198 113.24,-182.84 144.21,-177 168.3,-174.86"/>
<polygon points="168.26,-178.37 178,-174.18 167.78,-171.38 168.26,-178.37"/>
</g>
<g class="m-edge">
<title>p0x7f95e780ad70&#45;&gt;p0x7f95e780aa10</title>
<path d="M35.16,-302.33C44.54,-322.66 63.03,-355.67 90,-372 113.61,-386.29 144.81,-389.93 168.9,-390.19"/>
<polygon points="168.62,-393.69 178.58,-390.09 168.55,-386.69 168.62,-393.69"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a470&#45;&gt;p0x7f95e780a110</title>
<path d="M404.94,-249.66C408.12,-252.58 411.29,-255.77 414,-259 433.72,-282.55 424.13,-301.44 450,-318 501.39,-350.9 575.01,-350.76 618.91,-346.9"/>
<polygon points="619.09,-350.4 628.69,-345.92 618.39,-343.44 619.09,-350.4"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a470&#45;&gt;p0x7f95e780a350</title>
<path d="M401.93,-251.27C406.15,-256.36 410.57,-262.21 414,-268 435.56,-304.35 428.44,-319.65 450,-356 451.56,-358.62 453.31,-361.26 455.16,-363.83"/>
<polygon points="452.24,-365.78 461.14,-371.53 457.77,-361.49 452.24,-365.78"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a470&#45;&gt;p0x7f95e780a230</title>
<path d="M409.83,-225.7C440.87,-211.05 497.98,-184.1 533.87,-167.16"/>
<polygon points="535.36,-170.33 542.91,-162.9 532.37,-164 535.36,-170.33"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809ed0</title>
<ellipse cx="747" cy="-198" rx="27" ry="18"/>
<text text-anchor="middle" x="747" y="-194.12" font-family="Helvetica,sans-Serif" font-size="10.00">16</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a470&#45;&gt;p0x7f95e7809ed0</title>
<path d="M414.03,-233.24C476.68,-226.59 636,-209.68 708.75,-201.95"/>
<polygon points="708.98,-205.45 718.56,-200.91 708.24,-198.49 708.98,-205.45"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a110&#45;&gt;p0x7f95e7809ed0</title>
<path d="M667.51,-325.1C672.49,-316.18 678.64,-305.04 684,-295 700.47,-264.13 699.65,-253.46 720,-225 720.97,-223.64 722.01,-222.29 723.09,-220.95"/>
<polygon points="725.59,-223.39 729.59,-213.58 720.35,-218.76 725.59,-223.39"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809db0</title>
<ellipse cx="837" cy="-75" rx="27" ry="18"/>
<text text-anchor="middle" x="837" y="-71.12" font-family="Helvetica,sans-Serif" font-size="10.00">17</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a110&#45;&gt;p0x7f95e7809db0</title>
<path d="M668.32,-325.48C673.52,-316.67 679.63,-305.51 684,-295 706.03,-242.01 688.05,-218.67 720,-171 737.08,-145.51 750.34,-147.53 774,-128 786.41,-117.76 800.02,-106.17 811.32,-96.44"/>
<polygon points="813.39,-99.28 818.67,-90.09 808.81,-93.98 813.39,-99.28"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809810</title>
<ellipse cx="1107" cy="-381" rx="27" ry="18"/>
<text text-anchor="middle" x="1107" y="-377.12" font-family="Helvetica,sans-Serif" font-size="10.00">22</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a110&#45;&gt;p0x7f95e7809810</title>
<path d="M678.93,-352.81C707.6,-366.95 761.11,-390.99 810,-400 902.67,-417.08 1014.09,-400.04 1070.11,-388.92"/>
<polygon points="1070.62,-392.39 1079.72,-386.96 1069.22,-385.53 1070.62,-392.39"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809930</title>
<ellipse cx="1107" cy="-549" rx="27" ry="18"/>
<text text-anchor="middle" x="1107" y="-545.12" font-family="Helvetica,sans-Serif" font-size="10.00">21</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a110&#45;&gt;p0x7f95e7809930</title>
<path d="M673.65,-356.44C718.54,-396.75 853.36,-509.92 990,-547 1015.66,-553.96 1045.69,-554.28 1068.77,-552.95"/>
<polygon points="1068.92,-556.45 1078.64,-552.24 1068.41,-549.47 1068.92,-556.45"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a590&#45;&gt;p0x7f95e780a470</title>
<path d="M311.68,-140.42C315.71,-145.06 320.08,-150.19 324,-155 339.06,-173.48 355.42,-194.91 367.55,-211.09"/>
<polygon points="364.47,-212.82 373.26,-218.73 370.08,-208.63 364.47,-212.82"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a590&#45;&gt;p0x7f95e780a110</title>
<path d="M321.37,-133.5C373.96,-153.37 504,-206.79 594,-280 608.35,-291.67 623.04,-306.23 634.52,-318.31"/>
<polygon points="631.85,-320.57 641.23,-325.48 636.96,-315.79 631.85,-320.57"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a590&#45;&gt;p0x7f95e7809ed0</title>
<path d="M313.89,-111.02C343.55,-86.43 410.3,-38 476,-38 476,-38 476,-38 568,-38 646.64,-38 706.29,-125.45 732.05,-171.04"/>
<polygon points="728.84,-172.47 736.72,-179.55 734.97,-169.1 728.84,-172.47"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a590&#45;&gt;p0x7f95e7809db0</title>
<path d="M307.59,-108.03C318.32,-90.38 337.23,-63 360,-46 404.44,-12.81 420.54,0 476,0 476,0 476,0 658,0 715.23,0 775.26,-33.33 808.92,-55.55"/>
<polygon points="806.6,-58.2 816.84,-60.92 810.52,-52.41 806.6,-58.2"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a350&#45;&gt;p0x7f95e780a230</title>
<path d="M484.61,-370.26C499.78,-329.59 537.17,-229.32 555.51,-180.14"/>
<polygon points="558.69,-181.63 558.9,-171.04 552.13,-179.19 558.69,-181.63"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a350&#45;&gt;p0x7f95e7809db0</title>
<path d="M489.59,-371.6C521.69,-327.18 616.22,-202.86 720,-128 733.93,-117.95 773.6,-100.61 802.68,-88.51"/>
<polygon points="803.92,-91.78 811.83,-84.73 801.25,-85.31 803.92,-91.78"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809a50</title>
<ellipse cx="1017" cy="-465" rx="27" ry="18"/>
<text text-anchor="middle" x="1017" y="-461.12" font-family="Helvetica,sans-Serif" font-size="10.00">20</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a350&#45;&gt;p0x7f95e7809a50</title>
<path d="M480.11,-406.17C484.95,-440.41 499.71,-515.23 540,-562 578.15,-606.29 597.54,-624 656,-624 656,-624 656,-624 838,-624 896.46,-624 911.09,-601.7 954,-562 975.36,-542.24 992.48,-513.57 1003.28,-492.53"/>
<polygon points="1006.37,-494.18 1007.66,-483.66 1000.09,-491.07 1006.37,-494.18"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a350&#45;&gt;p0x7f95e7809810</title>
<path d="M486.56,-405.12C508.53,-446.4 571.23,-548 656,-548 656,-548 656,-548 838,-548 921.39,-548 918.54,-480.99 990,-438 1017.18,-421.65 1049.71,-405.98 1073.4,-395.22"/>
<polygon points="1074.53,-398.54 1082.22,-391.26 1071.67,-392.16 1074.53,-398.54"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a230&#45;&gt;p0x7f95e780a110</title>
<path d="M575.96,-169.2C591.24,-202.18 624.77,-274.58 643.22,-314.4"/>
<polygon points="639.98,-315.73 647.35,-323.33 646.33,-312.79 639.98,-315.73"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a230&#45;&gt;p0x7f95e7809ed0</title>
<path d="M593.58,-156.25C617.25,-160.43 653.3,-167.42 684,-176 693.38,-178.62 703.4,-181.94 712.58,-185.2"/>
<polygon points="711.26,-188.44 721.85,-188.58 713.65,-181.86 711.26,-188.44"/>
</g>
<g class="m-edge">
<title>p0x7f95e780a230&#45;&gt;p0x7f95e7809db0</title>
<path d="M590.91,-143.22C620.44,-132.12 673.51,-112.91 720,-100 746.2,-92.72 776.22,-86.3 799.16,-81.79"/>
<polygon points="799.81,-85.23 808.96,-79.9 798.48,-78.36 799.81,-85.23"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809c90</title>
<ellipse cx="837" cy="-373" rx="27" ry="18"/>
<text text-anchor="middle" x="837" y="-369.12" font-family="Helvetica,sans-Serif" font-size="10.00">18</text>
</g>
<g class="m-edge">
<title>p0x7f95e780a230&#45;&gt;p0x7f95e7809c90</title>
<path d="M584.35,-165.8C612.13,-189.21 670.34,-238.14 720,-279 750.92,-304.45 786.77,-333.41 810.33,-352.38"/>
<polygon points="807.86,-354.89 817.85,-358.43 812.25,-349.44 807.86,-354.89"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809ed0&#45;&gt;p0x7f95e7809db0</title>
<path d="M761.39,-182.38C765.58,-177.27 770.12,-171.5 774,-166 791.73,-140.91 792.27,-132.09 810,-107 811.76,-104.51 813.65,-101.96 815.59,-99.45"/>
<polygon points="818.18,-101.81 821.66,-91.81 812.7,-97.45 818.18,-101.81"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809ed0&#45;&gt;p0x7f95e7809810</title>
<path d="M772.31,-190.85C812.4,-180.48 893.92,-165.41 954,-194 1023.83,-227.23 1072.06,-309.96 1093.48,-353.39"/>
<polygon points="1090.21,-354.66 1097.69,-362.16 1096.52,-351.63 1090.21,-354.66"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809b70</title>
<ellipse cx="927" cy="-221" rx="27" ry="18"/>
<text text-anchor="middle" x="927" y="-217.12" font-family="Helvetica,sans-Serif" font-size="10.00">19</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809ed0&#45;&gt;p0x7f95e7809b70</title>
<path d="M773.88,-201.34C804.2,-205.26 854.66,-211.78 889.08,-216.23"/>
<polygon points="888.22,-219.65 898.58,-217.46 889.12,-212.7 888.22,-219.65"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e78096f0</title>
<ellipse cx="1197" cy="-221" rx="27" ry="18"/>
<text text-anchor="middle" x="1197" y="-217.12" font-family="Helvetica,sans-Serif" font-size="10.00">23</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809ed0&#45;&gt;p0x7f95e78096f0</title>
<path d="M769.18,-187.1C780.88,-181.69 795.87,-175.74 810,-173 833.56,-168.43 840,-172.73 864,-173 904.01,-173.44 914.2,-170.94 954,-175 1034.91,-183.26 1054.19,-192.32 1134,-208 1142.38,-209.65 1151.39,-211.49 1159.87,-213.26"/>
<polygon points="1159,-216.66 1169.51,-215.29 1160.45,-209.81 1159,-216.66"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809db0&#45;&gt;p0x7f95e7809a50</title>
<path d="M843.41,-92.77C853.29,-124.49 875.48,-192.73 900,-248 931.4,-318.8 976.51,-398.15 1000.15,-438.44"/>
<polygon points="997.09,-440.13 1005.19,-446.96 1003.12,-436.57 997.09,-440.13"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809db0&#45;&gt;p0x7f95e7809b70</title>
<path d="M848.09,-91.75C863.28,-116.94 892.13,-164.81 910.14,-194.69"/>
<polygon points="907.08,-196.39 915.24,-203.15 913.08,-192.78 907.08,-196.39"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809db0&#45;&gt;p0x7f95e78096f0</title>
<path d="M863.22,-69.71C917.83,-59.75 1048.96,-43.96 1134,-101 1165.32,-122.01 1181.76,-163.99 1189.65,-192.29"/>
<polygon points="1186.18,-192.85 1192.07,-201.66 1192.96,-191.1 1186.18,-192.85"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809150</title>
<ellipse cx="1467" cy="-273" rx="27" ry="18"/>
<text text-anchor="middle" x="1467" y="-269.12" font-family="Helvetica,sans-Serif" font-size="10.00">28</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809db0&#45;&gt;p0x7f95e7809150</title>
<path d="M861.62,-66.84C873.1,-63.11 887.15,-58.89 900,-56 950.83,-44.56 963.89,-39 1016,-39 1016,-39 1016,-39 1288,-39 1389.9,-39 1441.12,-181.3 1458.73,-243.96"/>
<polygon points="1455.34,-244.83 1461.33,-253.57 1462.1,-243 1455.34,-244.83"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809a50&#45;&gt;p0x7f95e7809810</title>
<path d="M1033.33,-450.37C1046.87,-437.44 1066.84,-418.38 1082.42,-403.51"/>
<polygon points="1084.64,-406.23 1089.46,-396.79 1079.81,-401.16 1084.64,-406.23"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809a50&#45;&gt;p0x7f95e7809930</title>
<path d="M1033.33,-479.63C1046.87,-492.56 1066.84,-511.62 1082.42,-526.49"/>
<polygon points="1079.81,-528.84 1089.46,-533.21 1084.64,-523.77 1079.81,-528.84"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809a50&#45;&gt;p0x7f95e78096f0</title>
<path d="M1041.1,-456.14C1071.06,-444.24 1121.02,-422.88 1134,-408 1173.72,-362.44 1188.15,-290.67 1193.27,-250.59"/>
<polygon points="1196.74,-251.07 1194.41,-240.73 1189.79,-250.27 1196.74,-251.07"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e78095d0</title>
<ellipse cx="1197" cy="-427" rx="27" ry="18"/>
<text text-anchor="middle" x="1197" y="-423.12" font-family="Helvetica,sans-Serif" font-size="10.00">24</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809a50&#45;&gt;p0x7f95e78095d0</title>
<path d="M1043.37,-459.89C1066.89,-455.12 1102.84,-447.74 1134,-441 1142.38,-439.19 1151.38,-437.19 1159.86,-435.28"/>
<polygon points="1160.53,-438.71 1169.51,-433.09 1158.98,-431.89 1160.53,-438.71"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809810&#45;&gt;p0x7f95e78096f0</title>
<path d="M1117.25,-364.18C1132.46,-336.52 1162.88,-281.21 1181.14,-248.01"/>
<polygon points="1184.13,-249.85 1185.88,-239.4 1177.99,-246.48 1184.13,-249.85"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809810&#45;&gt;p0x7f95e7809150</title>
<path d="M1133.79,-377.71C1186.26,-370.42 1308.56,-350.35 1404,-311 1415.94,-306.08 1428.24,-299.02 1438.7,-292.32"/>
<polygon points="1440.44,-295.37 1446.84,-286.93 1436.57,-289.54 1440.44,-295.37"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809810&#45;&gt;p0x7f95e78095d0</title>
<path d="M1128.85,-391.9C1139.63,-397.53 1152.98,-404.51 1164.94,-410.77"/>
<polygon points="1163.16,-413.79 1173.65,-415.32 1166.41,-407.58 1163.16,-413.79"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809390</title>
<ellipse cx="1287" cy="-385" rx="27" ry="18"/>
<text text-anchor="middle" x="1287" y="-381.12" font-family="Helvetica,sans-Serif" font-size="10.00">26</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809810&#45;&gt;p0x7f95e7809390</title>
<path d="M1134.26,-381.59C1164.37,-382.27 1213.96,-383.38 1248.21,-384.15"/>
<polygon points="1248.04,-387.65 1258.11,-384.37 1248.2,-380.65 1248.04,-387.65"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809c90&#45;&gt;p0x7f95e7809930</title>
<path d="M849.22,-389.38C871.85,-421.06 926.28,-490.63 990,-525 1014.15,-538.03 1044.65,-544 1068.31,-546.72"/>
<polygon points="1067.85,-550.2 1078.15,-547.7 1068.54,-543.23 1067.85,-550.2"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809c90&#45;&gt;p0x7f95e7809b70</title>
<path d="M845.57,-355.69C856.33,-331.8 877.27,-287.73 900,-253 901.67,-250.45 903.5,-247.86 905.4,-245.32"/>
<polygon points="908,-247.67 911.43,-237.65 902.5,-243.35 908,-247.67"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809c90&#45;&gt;p0x7f95e78096f0</title>
<path d="M860.39,-363.49C921.55,-337.53 1091.59,-265.33 1163.36,-234.86"/>
<polygon points="1164.38,-238.23 1172.22,-231.1 1161.65,-231.78 1164.38,-238.23"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809c90&#45;&gt;p0x7f95e78095d0</title>
<path d="M859.11,-383.71C883.52,-396.69 924.15,-420.18 954,-447 973.05,-464.12 966.92,-480.9 990,-492 1051.52,-521.57 1129.68,-476.24 1169.73,-447.57"/>
<polygon points="1171.63,-450.51 1177.61,-441.76 1167.48,-444.88 1171.63,-450.51"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809930&#45;&gt;p0x7f95e78095d0</title>
<path d="M1121.37,-533.36C1125.55,-528.25 1130.1,-522.48 1134,-517 1151.6,-492.29 1152.4,-483.71 1170,-459 1171.77,-456.52 1173.67,-453.97 1175.61,-451.46"/>
<polygon points="1178.2,-453.83 1181.69,-443.82 1172.72,-449.47 1178.2,-453.83"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809930&#45;&gt;p0x7f95e7809390</title>
<path d="M1124.48,-534.98C1136.92,-524.45 1154.44,-509.71 1170,-497 1193.76,-477.59 1201.67,-475.04 1224,-454 1238.9,-439.96 1254.3,-422.84 1266.02,-409.17"/>
<polygon points="1268.38,-411.8 1272.17,-401.91 1263.04,-407.28 1268.38,-411.8"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e78094b0</title>
<ellipse cx="1377" cy="-192" rx="27" ry="18"/>
<text text-anchor="middle" x="1377" y="-188.12" font-family="Helvetica,sans-Serif" font-size="10.00">25</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809930&#45;&gt;p0x7f95e78094b0</title>
<path d="M1131.47,-541.07C1175.74,-524.74 1270.98,-482.86 1314,-412 1350.7,-351.55 1328.81,-324.47 1350,-257 1353.88,-244.65 1359.03,-231.33 1363.72,-219.98"/>
<polygon points="1366.94,-221.36 1367.61,-210.79 1360.49,-218.63 1366.94,-221.36"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809030</title>
<ellipse cx="1557" cy="-273" rx="27" ry="18"/>
<text text-anchor="middle" x="1557" y="-269.12" font-family="Helvetica,sans-Serif" font-size="10.00">29</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809930&#45;&gt;p0x7f95e7809030</title>
<path d="M1134.24,-549C1168.96,-549 1232.07,-549 1286,-549 1286,-549 1286,-549 1378,-549 1494.42,-549 1538.37,-373.41 1551.38,-302.34"/>
<polygon points="1554.81,-303.05 1553.08,-292.6 1547.92,-301.85 1554.81,-303.05"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809ff0</title>
<ellipse cx="747" cy="-252" rx="27" ry="18"/>
<text text-anchor="middle" x="747" y="-248.12" font-family="Helvetica,sans-Serif" font-size="10.00">15</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809ff0&#45;&gt;p0x7f95e7809db0</title>
<path d="M763.93,-237.44C767.54,-233.63 771.15,-229.36 774,-225 799.44,-186.11 817.83,-135.07 827.7,-103.68"/>
<polygon points="831.05,-104.71 830.62,-94.12 824.35,-102.66 831.05,-104.71"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809ff0&#45;&gt;p0x7f95e7809810</title>
<path d="M771.21,-260.36C832.69,-282.52 999.94,-342.78 1072.1,-368.79"/>
<polygon points="1070.82,-372.04 1081.42,-372.14 1073.19,-365.46 1070.82,-372.04"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809ff0&#45;&gt;p0x7f95e7809c90</title>
<path d="M761.34,-267.66C765.53,-272.77 770.07,-278.53 774,-284 791.48,-308.34 792.52,-316.66 810,-341 811.78,-343.48 813.68,-346.01 815.63,-348.53"/>
<polygon points="812.74,-350.52 821.71,-356.16 818.22,-346.16 812.74,-350.52"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809ff0&#45;&gt;p0x7f95e7809b70</title>
<path d="M773.5,-247.56C803.9,-242.26 854.93,-233.38 889.5,-227.36"/>
<polygon points="889.8,-230.86 899.05,-225.69 888.6,-223.96 889.8,-230.86"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809b70&#45;&gt;p0x7f95e7809a50</title>
<path d="M934.58,-238.52C939.88,-252.67 947.48,-273.09 954,-291 972.62,-342.17 993.82,-402.01 1005.98,-436.51"/>
<polygon points="1002.61,-437.49 1009.24,-445.76 1009.22,-435.16 1002.61,-437.49"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809b70&#45;&gt;p0x7f95e78096f0</title>
<path d="M953.9,-217.93C965,-216.76 978.12,-215.57 990,-215 1053.93,-211.91 1070.07,-211.91 1134,-215 1142.08,-215.39 1150.72,-216.06 1158.92,-216.82"/>
<polygon points="1158.3,-220.28 1168.59,-217.78 1158.99,-213.31 1158.3,-220.28"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809b70&#45;&gt;p0x7f95e7809390</title>
<path d="M949.86,-231.01C1010.65,-258.86 1181.97,-337.34 1253.74,-370.22"/>
<polygon points="1252.05,-373.3 1262.6,-374.28 1254.97,-366.93 1252.05,-373.3"/>
</g>
<g class="m-node m-flat">
<title>p0x7f95e7809270</title>
<ellipse cx="1377" cy="-284" rx="27" ry="18"/>
<text text-anchor="middle" x="1377" y="-280.12" font-family="Helvetica,sans-Serif" font-size="10.00">27</text>
</g>
<g class="m-edge">
<title>p0x7f95e7809b70&#45;&gt;p0x7f95e7809270</title>
<path d="M953.7,-224.61C1029.15,-235.22 1250.33,-266.33 1338.8,-278.77"/>
<polygon points="1338.24,-282.22 1348.63,-280.15 1339.22,-275.29 1338.24,-282.22"/>
</g>
<g class="m-edge">
<title>p0x7f95e78096f0&#45;&gt;p0x7f95e7809150</title>
<path d="M1223.82,-224.84C1262.96,-230.8 1339.59,-243.08 1404,-257 1412.69,-258.88 1422,-261.14 1430.69,-263.37"/>
<polygon points="1429.64,-266.71 1440.2,-265.86 1431.41,-259.94 1429.64,-266.71"/>
</g>
<g class="m-edge">
<title>p0x7f95e78096f0&#45;&gt;p0x7f95e7809390</title>
<path d="M1207.09,-237.93C1222.37,-266.41 1253.33,-324.12 1271.6,-358.17"/>
<polygon points="1268.3,-359.42 1276.12,-366.58 1274.47,-356.11 1268.3,-359.42"/>
</g>
<g class="m-edge">
<title>p0x7f95e78096f0&#45;&gt;p0x7f95e78094b0</title>
<path d="M1223.5,-216.85C1253.82,-211.91 1304.64,-203.63 1339.21,-197.99"/>
<polygon points="1339.45,-201.5 1348.76,-196.44 1338.33,-194.59 1339.45,-201.5"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809150&#45;&gt;p0x7f95e7809030</title>
<path d="M1494.4,-273C1501.89,-273 1510.18,-273 1518.2,-273"/>
<polygon points="1518.1,-276.5 1528.1,-273 1518.1,-269.5 1518.1,-276.5"/>
</g>
<g class="m-edge">
<title>p0x7f95e78095d0&#45;&gt;p0x7f95e7809390</title>
<path d="M1219.75,-416.62C1230.2,-411.63 1242.91,-405.57 1254.39,-400.08"/>
<polygon points="1255.61,-403.38 1263.13,-395.91 1252.6,-397.06 1255.61,-403.38"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809390&#45;&gt;p0x7f95e7809150</title>
<path d="M1313.93,-382.6C1338.82,-379.26 1376.58,-371.37 1404,-353 1424.13,-339.51 1440.57,-317.33 1451.45,-299.75"/>
<polygon points="1454.35,-301.71 1456.43,-291.32 1448.33,-298.15 1454.35,-301.71"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809390&#45;&gt;p0x7f95e7809270</title>
<path d="M1301.37,-369.66C1315.64,-353.27 1338.47,-327.08 1355.12,-307.96"/>
<polygon points="1357.58,-310.46 1361.51,-300.63 1352.31,-305.87 1357.58,-310.46"/>
</g>
<g class="m-edge">
<title>p0x7f95e7809270&#45;&gt;p0x7f95e7809150</title>
<path d="M1403.93,-280.76C1411.65,-279.79 1420.26,-278.72 1428.56,-277.68"/>
<polygon points="1428.96,-281.16 1438.45,-276.44 1428.1,-274.21 1428.96,-281.16"/>
</g>
<g class="m-edge">
<title>p0x7f95e78094b0&#45;&gt;p0x7f95e7809150</title>
<path d="M1393.73,-206.48C1407.25,-218.92 1426.93,-237.04 1442.35,-251.23"/>
<polygon points="1439.56,-253.42 1449.29,-257.62 1444.3,-248.27 1439.56,-253.42"/>
</g>
<g class="m-edge">
<title>p0x7f95e78094b0&#45;&gt;p0x7f95e7809030</title>
<path d="M1399.83,-201.93C1430.79,-216.02 1487.68,-241.91 1523.58,-258.25"/>
<polygon points="1522.07,-261.4 1532.62,-262.36 1524.97,-255.03 1522.07,-261.4"/>
</g>
</g>
</svg>
</div><p>With task parallelism, we flow computation naturally with the graph structure. The runtime autonomously distributes tasks across processor cores to obtain maximum task parallelism. You do not need to worry about details of scheduling.</p></section><section id="GraphTraversalDynamicTraversal"><h2><a href="#GraphTraversalDynamicTraversal">Dynamic Traversal</a></h2><p>We can traverse the graph dynamically using <a href="classtf_1_1Subflow.html" class="m-doc">tf::<wbr />Subflow</a> (see <a href="SubflowTasking.html" class="m-doc">Subflow Tasking</a>). We start from the source nodes of zero incoming edges and recursively spawn subflows whenever the dependency of a node is meet. Since we are creating tasks from the execution context of another task, we need to store the task callable in advance.</p><pre class="m-code"><span class="n">tf</span><span class="o">::</span><span class="n">Taskflow</span><span class="w"> </span><span class="n">taskflow</span><span class="p">;</span>
<span class="n">tf</span><span class="o">::</span><span class="n">Executor</span><span class="w"> </span><span class="n">executor</span><span class="p">;</span>

<span class="c1">// task callable of traversing a node using subflow</span>
<span class="n">std</span><span class="o">::</span><span class="n">function</span><span class="o">&lt;</span><span class="kt">void</span><span class="p">(</span><span class="n">Node</span><span class="o">*</span><span class="p">,</span><span class="w"> </span><span class="n">tf</span><span class="o">::</span><span class="n">Subflow</span><span class="o">&amp;</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="n">traverse</span><span class="p">;</span>

<span class="n">traverse</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">&amp;</span><span class="p">]</span><span class="w"> </span><span class="p">(</span><span class="n">Node</span><span class="o">*</span><span class="w"> </span><span class="n">n</span><span class="p">,</span><span class="w"> </span><span class="n">tf</span><span class="o">::</span><span class="n">Subflow</span><span class="o">&amp;</span><span class="w"> </span><span class="n">subflow</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">assert</span><span class="p">(</span><span class="o">!</span><span class="n">n</span><span class="o">-&gt;</span><span class="n">visited</span><span class="p">);</span>
<span class="w">  </span><span class="n">n</span><span class="o">-&gt;</span><span class="n">visited</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">true</span><span class="p">;</span>
<span class="w">  </span><span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">n</span><span class="o">-&gt;</span><span class="n">successors</span><span class="p">.</span><span class="n">size</span><span class="p">();</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="k">if</span><span class="p">(</span><span class="n">n</span><span class="o">-&gt;</span><span class="n">successors</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">-&gt;</span><span class="n">dependents</span><span class="p">.</span><span class="n">fetch_sub</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="n">subflow</span><span class="p">.</span><span class="n">emplace</span><span class="p">([</span><span class="n">s</span><span class="o">=</span><span class="n">n</span><span class="o">-&gt;</span><span class="n">successors</span><span class="p">[</span><span class="n">i</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="n">traverse</span><span class="p">](</span><span class="n">tf</span><span class="o">::</span><span class="n">Subflow</span><span class="w"> </span><span class="o">&amp;</span><span class="n">subflow</span><span class="p">){</span><span class="w"> </span>
<span class="w">        </span><span class="n">traverse</span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">subflow</span><span class="p">);</span><span class="w"> </span>
<span class="w">      </span><span class="p">}).</span><span class="n">name</span><span class="p">(</span><span class="n">n</span><span class="o">-&gt;</span><span class="n">name</span><span class="p">);</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">  </span><span class="p">}</span>
<span class="p">};</span>

<span class="c1">// create a graph</span>
<span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o">&lt;</span><span class="n">Node</span><span class="p">[]</span><span class="o">&gt;</span><span class="w"> </span><span class="n">nodes</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">make_dag</span><span class="p">(</span><span class="mi">100000</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">);</span>

<span class="c1">// find the source nodes (no incoming edges)</span>
<span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">Node</span><span class="o">*&gt;</span><span class="w"> </span><span class="n">src</span><span class="p">;</span>
<span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="k">if</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">dependents</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span>
<span class="w">    </span><span class="n">src</span><span class="p">.</span><span class="n">emplace_back</span><span class="p">(</span><span class="o">&amp;</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">]));</span>
<span class="w">  </span><span class="p">}</span>
<span class="p">}</span>

<span class="c1">// create only tasks for source nodes</span>
<span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">src</span><span class="p">.</span><span class="n">size</span><span class="p">();</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">taskflow</span><span class="p">.</span><span class="n">emplace</span><span class="p">([</span><span class="n">s</span><span class="o">=</span><span class="n">src</span><span class="p">[</span><span class="n">i</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="n">traverse</span><span class="p">](</span><span class="n">tf</span><span class="o">::</span><span class="n">Subflow</span><span class="o">&amp;</span><span class="w"> </span><span class="n">subflow</span><span class="p">){</span><span class="w"> </span>
<span class="w">    </span><span class="n">traverse</span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">subflow</span><span class="p">);</span><span class="w"> </span>
<span class="w">  </span><span class="p">}).</span><span class="n">name</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">name</span><span class="p">);</span>
<span class="p">}</span>

<span class="n">executor</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">taskflow</span><span class="p">).</span><span class="n">wait</span><span class="p">();</span>

<span class="c1">// after the graph is traversed, all nodes must be visited with no dependents</span>
<span class="k">for</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">num_nodes</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">assert</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">visited</span><span class="p">);</span>
<span class="w">  </span><span class="n">assert</span><span class="p">(</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">dependents</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span>
<span class="p">}</span></pre><p>A partial graph is shown as follows:</p><div class="m-graph"><svg style="width: 87.000rem; height: 68.700rem;" viewBox="0.00 0.00 870.00 687.00">
<g transform="scale(1 1) rotate(0) translate(4 683)">
<title>Taskflow</title>
<g class="m-cluster">
<title>cluster_p0x7fd36b804d90</title>
<polygon points="8,-152 8,-635 854,-635 854,-152 8,-152"/>
<text text-anchor="middle" x="431" y="-621.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 3</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c005e90</title>
<polygon points="16,-204 16,-608 764,-608 764,-204 16,-204"/>
<text text-anchor="middle" x="390" y="-594.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 3</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c005c50</title>
<polygon points="24,-291 24,-581 674,-581 674,-291 24,-291"/>
<text text-anchor="middle" x="349" y="-567.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 4</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c005a10</title>
<polygon points="32,-343 32,-554 584,-554 584,-343 32,-343"/>
<text text-anchor="middle" x="308" y="-540.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 6</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c005470</title>
<polygon points="40,-351 40,-527 494,-527 494,-351 40,-351"/>
<text text-anchor="middle" x="267" y="-513.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 9</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c005590</title>
<polygon points="48,-359 48,-500 404,-500 404,-359 48,-359"/>
<text text-anchor="middle" x="226" y="-486.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 11</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c0057d0</title>
<polygon points="56,-367 56,-473 314,-473 314,-367 56,-367"/>
<text text-anchor="middle" x="185" y="-459.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 12</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c005350</title>
<polygon points="64,-375 64,-446 224,-446 224,-375 64,-375"/>
<text text-anchor="middle" x="144" y="-432.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 13</text>
</g>
<g class="m-cluster">
<title>cluster_p0x7fd36c005b30</title>
<polygon points="514,-212 514,-283 674,-283 674,-212 514,-212"/>
<text text-anchor="middle" x="594" y="-269.5" font-family="Helvetica,sans-Serif" font-size="10.00">Subflow: 4</text>
</g>
<g class="m-node m-flat">
<title>p0x7fd36b804c70</title>
<ellipse cx="99" cy="-18" rx="27" ry="18"/>
<text text-anchor="middle" x="99" y="-14.12" font-family="Helvetica,sans-Serif" font-size="10.00">0</text>
</g>
<g class="m-node m-flat">
<title>p0x7fd36b804a30</title>
<ellipse cx="99" cy="-72" rx="27" ry="18"/>
<text text-anchor="middle" x="99" y="-68.12" font-family="Helvetica,sans-Serif" font-size="10.00">1</text>
</g>
<g class="m-node m-flat">
<title>p0x7fd36b804b50</title>
<ellipse cx="99" cy="-126" rx="27" ry="18"/>
<text text-anchor="middle" x="99" y="-122.12" font-family="Helvetica,sans-Serif" font-size="10.00">2</text>
</g>
<g class="m-node m-flat">
<title>p0x7fd36b804d90</title>
<ellipse cx="819" cy="-208" rx="27" ry="18"/>
<text text-anchor="middle" x="819" y="-204.12" font-family="Helvetica,sans-Serif" font-size="10.00">3</text>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005e90</title>
<ellipse cx="729" cy="-238" rx="27" ry="18"/>
<text text-anchor="middle" x="729" y="-234.12" font-family="Helvetica,sans-Serif" font-size="10.00">3</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005e90&#45;&gt;p0x7fd36b804d90</title>
<path d="M753.58,-229.96C762.76,-226.83 773.45,-223.19 783.46,-219.77"/>
<polygon points="784.58,-223.09 792.92,-216.55 782.33,-216.46 784.58,-223.09"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005c50</title>
<ellipse cx="639" cy="-317" rx="27" ry="18"/>
<text text-anchor="middle" x="639" y="-313.12" font-family="Helvetica,sans-Serif" font-size="10.00">4</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005c50&#45;&gt;p0x7fd36c005e90</title>
<path d="M656.3,-302.7C661.92,-297.75 668.25,-292.14 674,-287 683.87,-278.17 694.68,-268.38 704.03,-259.88"/>
<polygon points="706.3,-262.55 711.34,-253.23 701.59,-257.37 706.3,-262.55"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005a10</title>
<ellipse cx="549" cy="-374" rx="27" ry="18"/>
<text text-anchor="middle" x="549" y="-370.12" font-family="Helvetica,sans-Serif" font-size="10.00">6</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005a10&#45;&gt;p0x7fd36c005c50</title>
<path d="M569.06,-361.67C573.93,-358.52 579.16,-355.13 584,-352 592.2,-346.69 601.1,-340.92 609.26,-335.63"/>
<polygon points="611,-338.68 617.49,-330.3 607.19,-332.8 611,-338.68"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005470</title>
<ellipse cx="459" cy="-381" rx="27" ry="18"/>
<text text-anchor="middle" x="459" y="-377.12" font-family="Helvetica,sans-Serif" font-size="10.00">9</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005470&#45;&gt;p0x7fd36c005a10</title>
<path d="M485.93,-378.94C493.65,-378.32 502.26,-377.64 510.56,-376.98"/>
<polygon points="510.75,-380.47 520.45,-376.19 510.2,-373.5 510.75,-380.47"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005590</title>
<ellipse cx="369" cy="-389" rx="27" ry="18"/>
<text text-anchor="middle" x="369" y="-385.12" font-family="Helvetica,sans-Serif" font-size="10.00">11</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005590&#45;&gt;p0x7fd36c005470</title>
<path d="M395.93,-386.64C403.65,-385.94 412.26,-385.16 420.56,-384.4"/>
<polygon points="420.8,-387.9 430.45,-383.5 420.17,-380.92 420.8,-387.9"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c0057d0</title>
<ellipse cx="279" cy="-397" rx="27" ry="18"/>
<text text-anchor="middle" x="279" y="-393.12" font-family="Helvetica,sans-Serif" font-size="10.00">12</text>
</g>
<g class="m-edge">
<title>p0x7fd36c0057d0&#45;&gt;p0x7fd36c005590</title>
<path d="M305.93,-394.64C313.65,-393.94 322.26,-393.16 330.56,-392.4"/>
<polygon points="330.8,-395.9 340.45,-391.5 330.17,-388.92 330.8,-395.9"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005350</title>
<ellipse cx="189" cy="-401" rx="27" ry="18"/>
<text text-anchor="middle" x="189" y="-397.12" font-family="Helvetica,sans-Serif" font-size="10.00">13</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005350&#45;&gt;p0x7fd36c0057d0</title>
<path d="M216.4,-399.8C223.89,-399.46 232.18,-399.08 240.2,-398.72"/>
<polygon points="240.27,-402.22 250.1,-398.27 239.96,-395.23 240.27,-402.22"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005230</title>
<ellipse cx="99" cy="-401" rx="27" ry="18"/>
<text text-anchor="middle" x="99" y="-397.12" font-family="Helvetica,sans-Serif" font-size="10.00">14</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005230&#45;&gt;p0x7fd36c005350</title>
<path d="M126.4,-401C133.89,-401 142.18,-401 150.2,-401"/>
<polygon points="150.1,-404.5 160.1,-401 150.1,-397.5 150.1,-404.5"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c0058f0</title>
<ellipse cx="549" cy="-317" rx="27" ry="18"/>
<text text-anchor="middle" x="549" y="-313.12" font-family="Helvetica,sans-Serif" font-size="10.00">6</text>
</g>
<g class="m-edge">
<title>p0x7fd36c0058f0&#45;&gt;p0x7fd36c005c50</title>
<path d="M576.4,-317C583.89,-317 592.18,-317 600.2,-317"/>
<polygon points="600.1,-320.5 610.1,-317 600.1,-313.5 600.1,-320.5"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005b30</title>
<ellipse cx="639" cy="-238" rx="27" ry="18"/>
<text text-anchor="middle" x="639" y="-234.12" font-family="Helvetica,sans-Serif" font-size="10.00">4</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005b30&#45;&gt;p0x7fd36c005e90</title>
<path d="M666.4,-238C673.89,-238 682.18,-238 690.2,-238"/>
<polygon points="690.1,-241.5 700.1,-238 690.1,-234.5 690.1,-241.5"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c0056b0</title>
<ellipse cx="549" cy="-238" rx="27" ry="18"/>
<text text-anchor="middle" x="549" y="-234.12" font-family="Helvetica,sans-Serif" font-size="10.00">7</text>
</g>
<g class="m-edge">
<title>p0x7fd36c0056b0&#45;&gt;p0x7fd36c005b30</title>
<path d="M576.4,-238C583.89,-238 592.18,-238 600.2,-238"/>
<polygon points="600.1,-241.5 610.1,-238 600.1,-234.5 600.1,-241.5"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36c005d70</title>
<ellipse cx="729" cy="-178" rx="27" ry="18"/>
<text text-anchor="middle" x="729" y="-174.12" font-family="Helvetica,sans-Serif" font-size="10.00">3</text>
</g>
<g class="m-edge">
<title>p0x7fd36c005d70&#45;&gt;p0x7fd36b804d90</title>
<path d="M753.58,-186.04C762.76,-189.17 773.45,-192.81 783.46,-196.23"/>
<polygon points="782.33,-199.54 792.92,-199.45 784.58,-192.91 782.33,-199.54"/>
</g>
<g class="m-node m-flat">
<title>p0x7fd36b804eb0</title>
<ellipse cx="99" cy="-661" rx="27" ry="18"/>
<text text-anchor="middle" x="99" y="-657.12" font-family="Helvetica,sans-Serif" font-size="10.00">4</text>
</g>
</g>
</svg>
</div><p>In general, the dynamic version of graph traversal is slower than the static version due to the overhead incurred by spawning subflows. However, it may be useful for the situation where the graph structure is unknown at once but being partially explored during the traversal.</p></section>
      </div>
    </div>
  </div>
</article></main>
<div class="m-doc-search" id="search">
  <a href="#!" onclick="return hideSearch()"></a>
  <div class="m-container">
    <div class="m-row">
      <div class="m-col-m-8 m-push-m-2">
        <div class="m-doc-search-header m-text m-small">
          <div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
          <div id="search-symbolcount">&hellip;</div>
        </div>
        <div class="m-doc-search-content">
          <form>
            <input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
          </form>
          <noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
          <div id="search-help" class="m-text m-dim m-text-center">
            <p class="m-noindent">Search for symbols, directories, files, pages or
            modules. You can omit any prefix from the symbol or file path; adding a
            <code>:</code> or <code>/</code> suffix lists all members of given symbol or
            directory.</p>
            <p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
            / <span class="m-label m-dim">&uarr;</span> to navigate through the list,
            <span class="m-label m-dim">Enter</span> to go.
            <span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
            copy a link to the result using <span class="m-label m-dim">⌘</span>
            <span class="m-label m-dim">L</span> while <span class="m-label m-dim">⌘</span>
            <span class="m-label m-dim">M</span> produces a Markdown link.</p>
          </div>
          <div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
          <ul id="search-results"></ul>
        </div>
      </div>
    </div>
  </div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
  <div class="m-container">
    <div class="m-row">
      <div class="m-col-l-10 m-push-l-1">
        <p>Taskflow handbook is part of the <a href="https://taskflow.github.io">Taskflow project</a>, copyright © <a href="https://tsung-wei-huang.github.io/">Dr. Tsung-Wei Huang</a>, 2018&ndash;2024.<br />Generated by <a href="https://doxygen.org/">Doxygen</a> 1.9.6 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
      </div>
    </div>
  </div>
</nav></footer>
</body>
</html>
